<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"></script>
    <style>
        .act-enter-from{
            opacity: 0;
            transform: translateX(100px);
        }
        .act-enter-to{
            opacity: 1;
            transform: translateX(0px);
        }
        .act-enter-active{
            transition: all 3s;
        }
        .act-leave-from{
            opacity: 1;
            transform: translateX(0px);
        }
        .act-leave-to{
            opacity: 0;
            transform: translateX(100px);
        }
        .act-leave-active{
            transition: all 3s;
        }
    </style>
</head>
<body>
    <div id="app">
        <button @click="flag=!flag">切换</button>
        <transition name="act" mode="out-in">
            <h1 v-if="flag">请稍后。。。。</h1>
            <h1 v-if="!flag">要离开。。。。</h1>
        </transition>
    </div>
</body>
</html>
<script>
    const app = Vue.createApp({
        data() {
            return {
                flag:true
            }
        },
    })
    app.mount('#app')
</script>